﻿﻿using Nancy;
using Nancy.Bootstrapper;
using Nancy.Conventions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Nancy.Session;
using Nancy.TinyIoc;

namespace ConfigServer
{
    public class CustomBootstrapper : DefaultNancyBootstrapper
    {
        protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
        {
                
            pipelines.AfterRequest.AddItemToEndOfPipeline(ctx =>
            {
                ctx.Response.Headers.Add("Access-Control-Allow-Origin", "*");
                ctx.Response.Headers.Add("Access-Control-Allow-Methods", "POST,GET,DELETE,PUT,OPTIONS");                
                ctx.Response.Headers.Add("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, Authorization");
            });

            CookieBasedSessions.Enable(pipelines);
        }
    }
}